Comments (6)
Hello there,
Thanks for bringing this to our attention. Indeed this does look unexpected.
I'm getting varying results with this label in different graphics devices, with some refusing to render some accents at all. I highly doubt that aspect of the issue can be fixed here. See examples below (I added a plain text to your example for reference),
ragg:
Cairo PNG:
Windows device:
As far as I can tell, the ragg device does the correct thing in the plain text. I think the issue might stem from a decoupling of the accents from the glyph to which they should be applied. Because they are registered as having zero width, the angles are incorrectly inferred by projecting the xmin and xmax positions, which is why they remain unrotated. I'm by no means an expert on unicode text representation, so I'm left wondering whether there is a reliable way of knowing glyph-accent relationships.
from geomtextpath.
I'm by no means an expert on unicode text representation, so I'm left wondering whether there is a reliable way of knowing glyph-accent relationships.
There is! The Unicode tables, specifically UnicodeData.txt, Canonical_Combining_Class section have this information
via the Unicode R package:
> install.packages("Unicode")
> library(unicode)
> u_char_properties(utf8ToInt("Composed: \u00ea, DeC: e\u0302, \u05aa\u05d0\u05aa"), "Canonical_Combining_Class")
Canonical_Combining_Class
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 0
11 0
12 0
13 0
14 0
15 0
16 0
17 0
18 0
19 0
20 230
21 0
22 0
23 220
24 0
25 220
>
The 0's are normal letters, details here: https://www.unicode.org/reports/tr44/#Canonical_Combining_Class_Values
Alternatively, one could check the class, as All characters other than those of General_Category Mn or Mc are guaranteed to have Canonical_Combining_Class=0.
:
u_char_properties(utf8ToInt("Composed: \u00ea, DeC: e\u0302, \u05aa\u05d0\u05aa #"), "General_Category")
I'm unsure if there is another R package that is more high level, but that is the base data that it would use too.
from geomtextpath.
Oh and for reference my screenshot was taken on X11, and the plain text looks like ragg/the correct rendering
from geomtextpath.
One possible, cheap solution that I could find is to put zero-width glyphs together with the preceding glyph. I don't know whether that has any drawbacks at the moment.
Because a space precedes the first \u05aa
character, it gets rendered awkwardly. This would still happen if we did a more fancy thing with Unicode::u_char_properties()
though.
from geomtextpath.
Yes, the extra U+05AA was an error that was how I discovered the RTL issues :-)
That approach may have some drawbacks. This table (ignore the tailored clusters) has some nice examples, particularly Hangul (แแ กแจ): https://www.unicode.org/reports/tr29/#Table_Sample_Grapheme_Clusters
There are some libraries for this algorithm, and for R integration I am currently investigating utf8proc or maybe something in the style of https://github.com/foliojs/grapheme-breaker for a pure R implement
from geomtextpath.
This should now also be fixed, so I'll be closing this.
from geomtextpath.
Related Issues (20)
- Long labels with arrow throw cryptic "Error: Cannot create zero-length unit vector ("unit" subsetting)" error
- Strange behaviour of halign HOT 4
- Feature Request: Set angle for geom_labelvline HOT 6
- Feature request - test for text self-overlap on sharp contours HOT 1
- ggplot coord_polar() issue with multiple classes: 'from' must be a finite number error HOT 1
- session aborted when library in Rstudio HOT 2
- Add compatibility with `ggbump` HOT 2
- geom_textsf randomly throws erros when specification of font family is missing (OpenSUSE Leap 15.5, R 4.3.2) HOT 2
- Release geomtextpath 0.1.2 HOT 1
- library(geomtextpath) abort the R session HOT 2
- Prevent rounding of numeric labels HOT 2
- geomtextpath example code does not seem to work
- Warning messages: "All aesthetics have length 1, but the data has XX rows" HOT 2
- vjust and hjust as aesthetics in geom_textsf HOT 3
- Different behavior for line breaks when there's no data
- geomtextline not accommodating RGBA colors
- show.legend not working in geom_textabline
- Support for `geom_step()`? HOT 2
- Partial match of 'xoff' to 'xoffset'
- geom_textsf seems to ignore remove_long=F
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geomtextpath.