Open gcmartijn opened 9 years ago
Hiya,
This is probably since been addressed long ago, but the reason why it doesn't currently support Unicode is due to the legacy usage of chars[]. This was addressed by switching the variable to a map in http://github.com/nobuyukinyuu/monkey-utf8 but I considered the loss of efficiency unacceptable considering Angelfont has to perform the lookup every frame (and for every character? I can't remember now...). You can use that as a workaround but it may not be acceptable depending on how much text you need to display.
I was experimenting with implementing a splay tree to reduce the lookup times of an Angelfont char but opted instead to write a new class entirely for baking/caching rendered bitmaps for strings intended for display in my angelfont successor Varifont. A prototype was being developed in late 2015 for my next project but went unreleased. At this point, many people have switched over to Mojo 2 and probably wouldn't benefit from an incomplete implementation...
H!
I'm using monkey and I was searching for a free compact (less code is better :)) font creator. The end combination is now: http://kvazars.com/littera/ There i'm exporting the bitmap as .txt for free.
And then I strip down your code (to test it first).
But I notice that everything works oke except special characters :( Are you planning to fix that in the near future ? If not, then i'm going to rewrite the code so it can handle the other characters.
Maybe you say, that you are planning to rewrite this yourself so I can concentrate on other code i;m working on.
Strict Import mojo
Class Font Global firstKp:IntMap
Global secondKp:KernPair
' Local prevChar:String = "" Local prevChar:Int = 0 xOffset = 0
' Local thisChar:String = String.FromChar(asc) Local thisChar:Int = asc If ac <> Null If useKerning firstKp = kernPairs.Get(prevChar) If firstKp <> Null secondKp = firstKp.Get(thisChar) If secondKp <> Null xOffset += secondKp.amount ' Print prevChar+","+thisChar End Endif Endif ac.Draw(image[ac.page], x+xOffset,y) xOffset += ac.xAdvance prevChar = thisChar Endif Next End Method
End Class
Class Char Field asc:Int Field x:Int Field y:Int
End Class
Class KernPair Field first:String Field second:String Field amount:Int
rem
' Return "first="+first+" second="+second+" amount="+amount End Method
end
End Class