microsoft / microsoft/WindowsAppSDK
DWriteCore returns shifted glyph indices in a glyph run
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 471
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 28
Description
### Describe the bug
I have noticed that some fonts (not all) just give wrong glyph indices when passed to `DrawGlyphRun` in the `DWRITE_GLYPH_RUN`. For example when i use FreeType to check the index for space in the [AppleStorm](https://www.dafont.com/applestorm.font) font I get the glyph index `1`. When i check on [FontDrop](https://fontdrop.info) I also get the index as `1` as shown in the screenshot.

Even when I ask DWriteCore itself to give me the glyph indices using `GetGlyphIndices`, it tells me space is glyph index `1`. But when layed out it gives me `3`. This results in situations like this, where with Open Sans it gives the correct result:

but when I switch to the offending font, it shifts it `2` indices to the right:

### Steps to reproduce the bug
1. Since i cannot attach font files, 1 font that definitely does not work is the [AppleStorm](https://www.dafont.com/applestorm.font) font.
2. Use that file to the retrieve some glyph indices using `GetGlyphIndices`, like space with codepoint `32`.
3. See that it returns glyph index `1` for space.
4. Then layout text and see that the glyph index it has given (in this font) is `3`.
### Expected behavior
DWriteCore returns the correct glyph indices for the given codepoints. The same it also returns in `GetGlyphIndices`.
### Screenshots
_No response_
### NuGet package version
None
### Packaging type
Unpackaged
### Windows version
Windows 11 version 22H2 (22621, 2022 Update)
### IDE
Visual Studio 2022
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the mismatch with the AppleStorm font, comparing GetGlyphIndices with the glyph indices produced during layout and passed to DrawGlyphRun in DWRITE_GLYPH_RUN. Trace the DWriteCore text-layout and glyph-index handling from those entry points; done means the layout returns the same indices as GetGlyphIndices for the affected font without shifting glyphs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100