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

Print: Poor Cyrillic support in Map Title, Map comment, when printing a map #1181

Closed
bitmapbulgaria opened this issue Sep 20, 2022 · 7 comments · Fixed by #1189
Closed

Print: Poor Cyrillic support in Map Title, Map comment, when printing a map #1181

bitmapbulgaria opened this issue Sep 20, 2022 · 7 comments · Fixed by #1189
Assignees
Labels
bug module:client/plugin Functionality that goes into plugins in client plugin:print
Projects
Milestone

Comments

@bitmapbulgaria
Copy link

Description:
When user prints a map with a title and comment, written in Cyrillic, the result is not readable.
On the example, there is two variants of the same print (in English, and in Cyrillic):

English:
image

Cyrillic:
image

To Reproduce:
Just try to print a map with a Title and comment in Cyrillic (I used Bulgarian layout) with Print plugin

Instance:

  • OS: Ubuntu 22.04
  • NodeJS version (new-admin, new-backend, new-client)
  • Browser Chrome, 92
  • Hajk Version 3.10.0, release candidate 2, master branch
@jacobwod jacobwod added the bug label Sep 20, 2022
@jacobwod jacobwod added this to Approved ideas in Hajk via automation Sep 20, 2022
@jacobwod jacobwod added this to the 3.x milestone Sep 20, 2022
@jacobwod jacobwod added the module:client/plugin Functionality that goes into plugins in client label Sep 20, 2022
@bitmapbulgaria
Copy link
Author

UPDATE: I solved the problem. This fix works with every TTF font , not only Cyrillic.

  1. I have generated binary representation of a TTF font, in my case FreeMonoBold.ttf (my file: http://bugis-robg.eu:1111/qgis/resources/ttfFont.js )

  2. Store it in the folder of the plugin, at /new-client/src/plugins/Print/

  3. Declaration of the constant in PrintModel.js with: import myTTFFont from "./ttfFont.js";

  4. Inserted a simple code for the title, comment and other text attributes of the map:

     pdf.addFileToVFS("MyFont.ttf", myTTFFont);
     pdf.addFont("MyFont.ttf", "MyFont", "normal");
     pdf.setFont("MyFont");
    
  5. Recompiled the Client part an publish it.

  6. My updated PrintModel.js is published at: http://bugis-robg.eu:1111/qgis/resources/PrintModel.js

P.S. I'm sure there is more elegant way to solve this, but I'm a JS noob and for now this is all I can make for the Cyrillic support. I hope this will help, cheers!

The result:
image

@Hallbergs
Copy link
Member

Good job solving it! I found a similar solution when i was investigating it yesterday! I will look into getting the fix into the next release. (We will probably have to incorporate some logic regarding how we select which font that should be set).

@Hallbergs
Copy link
Member

I added a similar solution to yours, (decided to go with the Roboto font, since we use it everywhere else in the application).

I added "normal" instead of "bold", and i think it might be a bit to thin? What do you think? @jesade-vbg @jacobwod @OlofSvahnVbg

image

image

Feel free to test other fonts in this branch: https://github.com/hajkmap/Hajk/tree/fix/1181-cyrillic-print-support

@Hallbergs Hallbergs self-assigned this Sep 21, 2022
@bitmapbulgaria
Copy link
Author

Hi! I think the Roboto font for Cyrillic texts font is awesome! In Cyrillic glyphs are a way rounded, than in English, so the font is even better in Cyr. Maybe it is not bad idea to have a menu for choosing a font from some pool (with, about 10-15 fonts) in the Print/settings window. But for now-Roboto Normal is very good. Thanks for the fix!

@jacobwod
Copy link
Member

jacobwod commented Sep 21, 2022

This is a great find @Hallbergs & @bitmapbulgaria.

I took a look at the feature branch and although I agree that we could expand it (by adding a font select menu, etc), I think that this already is a great feature and I'd love seeing it merged. 💯 🥇

Edit: Just adding a note here so we "connect" this issue with the related #502.

@jacobwod jacobwod moved this from Approved ideas to In progress in Hajk Sep 22, 2022
@bitmapbulgaria
Copy link
Author

bitmapbulgaria commented Sep 23, 2022

Just another small fix needed ( I have got hardcoded the value of these in Cyrillic and it works-I have setup my GeoServer Cyrillic aliases for the real field names):

  "searchFields": [
    "улица"
  ],

  "infobox": "",
  "aliasDict": "",
  "displayFields": [
    "улица"
  ],

  "shortDisplayFields": [
    "улица"
  ]

Otherwise, it is impossible to save Cyrillic values for the field names in Admin Panel:
image
This is a screenshot of the red colored inputs.

@Hallbergs Hallbergs linked a pull request Sep 27, 2022 that will close this issue
@Hallbergs Hallbergs modified the milestones: 3.x, 3.11 Sep 27, 2022
Hajk automation moved this from In progress to Done Sep 27, 2022
@Hallbergs
Copy link
Member

We'll close it when it's merged to master :)

@Hallbergs Hallbergs reopened this Sep 28, 2022
Hajk automation moved this from Done to Approved ideas Sep 28, 2022
@jacobwod jacobwod moved this from Approved ideas to Done in Hajk Sep 28, 2022
@jacobwod jacobwod changed the title Poor Cyrillic support in Map Title, Map comment, when printing a map Print: Poor Cyrillic support in Map Title, Map comment, when printing a map Sep 29, 2022
@jacobwod jacobwod closed this as completed Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug module:client/plugin Functionality that goes into plugins in client plugin:print
Projects
Hajk
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants