Giter Club home page Giter Club logo

Comments (3)

teunbrand avatar teunbrand commented on July 24, 2024

We do already support Chinese character, whether it is simplified or traditional. If you set the family to a font that does have glyphs for these, it works perfectly fine. (Also took the liberty of answering the SO question)

library(tidyverse)
library(geomtextpath)
plot_data_2 <- data.frame(category=c('品类A','品类B','品类C','品类D'),
                          amount=c(1,6,4,7))

plot_data_2 %>% ggplot(aes(x=1,y=amount,fill=category))+
  geom_col()+geom_textpath(position = position_stack(vjust=0.5),
                           aes(label=category),
                           family = "Noto Sans TC")+
  coord_polar() +
  theme(legend.text = element_text(family = "Noto Sans TC"))

The issue is that the default font doesn't include glyphs for Chinese characters, which makes our 'convert font index back to glyph' step not work as intended. This is also why some BiDi test of ours doesn't work on MacOS, since the default font doesn't contain Hebrew glyphs (I presume).

While this step solves a lot of other issues for us, this step makes font fallback impossible (which is what graphics devices, including {ragg}, do behind the scenes). I've submitted a feature request at {textshaping} a while back, asking to return sensible representations of glyphs. If we get to be blessed on this topic on {textshaping}'s side, we don't need the conversion step, and thus font fallback would work as intended.

from geomtextpath.

AllanCameron avatar AllanCameron commented on July 24, 2024

Ah! I didn't have time to look at this in any detail earlier. I know from my work in parsing pdfs that vertical writing is sometimes used in CJK scripts, which presumably we can't realistically support, but it's good to know that there isn't anything we are doing to inherently suppress the glyphs.

Since we have our own fallback font mechanism now (including a freeware font) I wonder if we should think about using a maximally inclusive fallback font that contains these glyphs and a mechanism for using them where necessary.

Thanks for clarifying, and for answering the SO post.

from geomtextpath.

teunbrand avatar teunbrand commented on July 24, 2024

which presumably we can't realistically support,

I'm not exactly sure what the expectation would be for vertical text, as I don't think I've used it other than playing around with WordArt in the 90s. Would it be to place text on a straight line orthogonal to the curve? Or would it be a 90° rotation per-letter? I think that you can make a case for the text orthogonal to the curve. For example in the usecase of this type of plot, it would be nice if one could label the year orthogonally.

I wonder if we should think about using a maximally inclusive fallback font

I think there is a technical limitation to fonts that makes it such that a font can't contain all unicode glyphs (discussion here). We could try to use systemfonts::font_fallback(), but I'm not sure how much overhead this adds, especially since it would need to be called for every substring. E.g. systemfonts::font_fallback(unlist(strsplit('品类A', ""))).

from geomtextpath.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.