Add CJK font support and fallback mechanism in AFont class - #762
Open
luadebug wants to merge 53 commits into
Open
Add CJK font support and fallback mechanism in AFont class#762luadebug wants to merge 53 commits into
luadebug wants to merge 53 commits into
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
luadebug
marked this pull request as draft
July 28, 2026 07:41
Nelonn
requested changes
Jul 28, 2026
| }; | ||
| static const AString fontsDir = [] { | ||
| char buf[MAX_PATH]; | ||
| UINT len = GetWindowsDirectoryA(buf, MAX_PATH); |
Contributor
There was a problem hiding this comment.
Do not use A-suffixed winapi methods
Collaborator
There was a problem hiding this comment.
use GetWindowsDirectory instead
Contributor
There was a problem hiding this comment.
Use GetWindowsDirectoryW instead
| return FT_Get_Char_Index(mFace, codepoint) != 0; | ||
| } | ||
|
|
||
| void AFont::ensureFallbackFace() { |
Contributor
There was a problem hiding this comment.
Why fallback font is stored per font and not per font manager?
luadebug
marked this pull request as ready for review
July 29, 2026 00:14
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Nelonn
requested changes
Jul 29, 2026
| return FT_Get_Char_Index(mFace, codepoint) != 0; | ||
| } | ||
|
|
||
| void AFontManager::ensureFallbackFace() { |
… fallback font resources
… proper mutex locking in AFontManager
…uce scoped locking for thread safety
…aceLocked and improve fallback face handling with scoped locking
…s are captured while the fallback lock is held
…, including pre-warming fallback faces and improving glyph metrics capture.
…, including the introduction of FallbackCandidate struct and pre-warming fallback faces to enhance performance.
…, including improvements to fallback face management and glyph rendering logic.
…oving unused fallback font path and data buffer, and simplifying fallback face loading logic.
…ack font loading, simplifying logic and improving performance.
…e character advance calculations and kerning handling.
…twareRenderer to unify handling of empty glyphs, ensuring consistent rendering and measurement across components.
…ate calls in OpenGLRenderer and SoftwareRenderer for improved kerning calculations.
… OpenGLRenderer, and SoftwareRenderer to improve thread safety and handle glyph loading failures more effectively.
…d CJK support and deferred loading of candidates.
…ge for glyph rendering and fallback face loading
…ode support and update related calls in AFontManager for better handling of CJK fonts.
…g mutex usage for glyph rendering and fallback face loading, ensuring proper locking during FreeType operations.
…ding documentation for AFontManager pointer usage in AFont.
…andling, ensuring thread safety and efficient memory usage in AFont and AFontManager.
…visional glyphs, improving fallback discovery on a separate thread, and refining mutex usage for better thread safety in AFont and AFontManager.
…safety in AFontManager and updating CharEntry to use shared references for images in SoftwareRenderer, ensuring proper memory management during glyph re-rendering.
…Font, ensuring that provisional and failed glyphs are handled correctly during re-renders, and refining fallback face loading in AFontManager with error logging for missing fonts.
…s in AFontManager, ensuring robustness during font fallback processes.
…ing that cached failed/provisional glyphs are re-rendered at most once per fallback face load, improving efficiency during font rendering processes.
… reprogramming in AFont, ensuring that the primary face's size is only set when needed. Additionally, include SharedPtrTypes header in AFont.h for improved memory management.
- Introduced a new function `programPixelSize` to encapsulate pixel size programming logic for font faces, improving code readability and maintainability. - Updated `AFont::renderGlyph` to utilize `programPixelSize`, simplifying the pixel size setting process and handling fallback logic more effectively. - Modified `AFontManager` to manage fallback font candidates across different platforms, implementing platform-specific logic for CJK font discovery. - Enhanced fallback candidate loading mechanisms for Windows, macOS, Linux, and Android, ensuring proper handling of system fonts. - Improved handling of font file reading by utilizing memory buffers to avoid file I/O during critical sections, reducing potential performance bottlenecks. - Adjusted glyph rendering logic in `SoftwareRenderer` to use float accumulators for advance calculations, ensuring more accurate text width measurements. - Added logging for fallback discovery failures and font loading issues to aid in debugging and user feedback.
…ncing thread safety and cache integrity during glyph rendering. Introduce fallback worker management in AFontManager for improved asynchronous font loading and fallback discovery.
…safely. Improve error handling for font loading in macOS by catching exceptions and logging warnings. Update fallback font paths to include CJK font names for better compatibility.
… glyphs from being downgraded to failed states. Improve fallback worker management in AFontManager to handle thread creation failures gracefully. Update fallback font paths for better compatibility with CJK fonts.
…iency. Introduce getCharacterLocked for locked access, ensuring cached glyphs are re-rendered only when necessary. Update AFontManager to streamline fallback discovery and remove unused deferred count tracking.
… thread safety in character data management. Introduce shared mutex for font cache to prevent data races during appends. Refactor empty advance logic for better consistency in glyph rendering.
…wn to prevent worker threads from outliving the manager. Update fallback worker management to ensure proper shutdown. Improve character handling in AFont to retain drawable glyphs during fallback generation updates.
…re floored for accurate glyph placement. Update AFontManager to detach fallback worker threads safely and enhance fallback candidate retrieval for iOS by using CoreText to access system CJK fonts.
… strikes with a slight size delta. Improve character data handling in OpenGLRenderer to ensure proper image association and prevent unnecessary texture updates. Update AFontManager to manage fallback face cleanup more effectively and ensure proper memory handling for font loading on iOS.
…t issues until rescaling logic is implemented.
…tilize a callback structure for symbol addition and glyph processing. Introduce walkString method in AFontStyle for improved text handling and advance calculations.
…back candidate handling. Update CMakeLists.txt to link necessary libraries. Refactor kerning calculations in AFontStyle and optimize character data handling in OpenGLRenderer.
…ion and update fallbackCandidates method to correctly push back candidates with faceIndex.
…ying lockFallbackFace callers. Update AFontManager to ensure proper synchronization during fallback discovery.
…date AFontManager to improve fallback thread management and ensure proper synchronization. Enhance OpenGLRenderer to handle UV production more robustly and optimize glyph rendering. Modify AFontManagerImpl to correctly retrieve font paths for fallback candidates.
…g line height calculations, and updating character data structure to track fallback generation. This ensures better glyph management and synchronization during rendering.
…improve fallback face handling by utilizing move semantics for deferred candidates. Add face index retrieval for PostScript names in iOS font management.
…kerning logic. Update advanceY calculation in AFontStyle to ensure maximum value is used. Adjust memory face creation in AFontManagerImpl for better type safety with reinterpret_cast.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#646