Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in GlyphIndexList.Replace() #80

Closed
samhocevar opened this issue Nov 14, 2017 · 9 comments
Closed

Problem in GlyphIndexList.Replace() #80

samhocevar opened this issue Nov 14, 2017 · 9 comments

Comments

@samhocevar
Copy link
Contributor

At line 114 in GlyphIndexList.cs, _tmpGlypIndexBackup may be empty if the whole string was replaced with a ligature, so the code crashes there when accessing _tmpGlypIndexBackup[0].

I might be able to fix this later, but I do not really understand GlyphIndexToUserChar yet. Maybe you know what’s going on and can fix it more quickly than me :-)

@prepare
Copy link
Member

prepare commented Nov 14, 2017

Thank you,
fixed, see => 0735269


Disable Ligature and Enable Ligature, Palatino Font

fi_1

pic 1: f-i Disable Ligature, 2 glyph indices (f and i)


fi_2

pic 2: f-i Enable Ligature, 2 glyph indices are replaced with 1 f-i glyph index

@prepare prepare closed this as completed Nov 14, 2017
@prepare
Copy link
Member

prepare commented Nov 14, 2017

@samhocevar

when we do glyph substitution,
user input chars may not be mapped with output rendered glyph index 1:1. (see pic2 above)

so GlyphIndexToUserChar and related structures
are needed to store that mapping when developing a 'textbox' control.

@samhocevar
Copy link
Contributor Author

It looks like there is still a problem; see:

  1. List is emptied

         _tmpGlypIndexBackup.Clear();
    
  2. removeLen elements are added starting from 0:

         int endAt = index + removeLen;
         for (int i = index; i < endAt; ++i)
         {
             _tmpGlypIndexBackup.Add(_mapGlyphIndexToUserChar[i]);
         }
    
  3. removeLen elements are removed starting from index:

         _tmpGlypIndexBackup.RemoveRange(index, removeLen);
    

@prepare prepare reopened this Nov 15, 2017
@prepare
Copy link
Member

prepare commented Nov 15, 2017

@samhocevar,

removeLen must >=1 right ?

if so then _tmpGlypIndexBackup.Count must > 0

since collection count > 0
we pick the 1st glyph index before call RemoveRange()

_tmpGlypIndexBackup[0] should not crash.

from 0735269

@prepare
Copy link
Member

prepare commented Nov 16, 2017

@samhocevar ,

I see !

:)

see=> 776257e

@prepare
Copy link
Member

prepare commented Nov 16, 2017

replace1
pic 1: Palatino Linotype font

@samhocevar
Copy link
Contributor Author

OK! But then, is _tmpGlypIndexBackup really needed? We only take the first element, then it is emptied again 🤔

@prepare
Copy link
Member

prepare commented Nov 16, 2017

actually, not need.
I use it during debug.

see =>b981263

@prepare
Copy link
Member

prepare commented Nov 16, 2017

user_char-to-glyph_index , and glyph_index-to-user_char

more information

replace_4
pic 1: Palatino Linotype, Script=Latin, red lines are abstract

@prepare prepare closed this as completed Nov 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants