cannot write Chinese in linux - pdfbox

Question:I can generate Chinese watermark normally in windows environment and macos environment, but it reports an error in linux environment.
linux environment
java 1.8
pdfbox 3.0.0-alpha2
The system seems to have successfully installed the font
fc-list |grep STFangsong
/usr/share/fonts/zh_CN/STFANGSO.TTF: STFangsong:style=Regular
java.lang.IllegalArgumentException: No glyph for U+FFFD (?) in font STFangsong
at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:378) ~[pdfbox-3.0.0-alpha2.jar!/:3.0.0-alpha2]
at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:443) ~[pdfbox-3.0.0-alpha2.jar!/:3.0.0-alpha2]
at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:335) ~[pdfbox-3.0.0-alpha2.jar!/:3.0.0-alpha2]
at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:366) ~[pdfbox-3.0.0-alpha2.jar!/:3.0.0-alpha2]
at com.tencent.converter.service.PDFBox.processTextOnePage(PDFBox.java:117) ~[classes!/:0.0.1-SNAPSHOT]
at com.tencent.converter.service.PDFBox.addTextAllPageWAtermark(PDFBox.java:96) ~[classes!/:0.0.1-SNAPSHOT]
at com.tencent.converter.service.PDFBox.addTextWatermark(PDFBox.java:83) ~[classes!/:0.0.1-SNAPSHOT]
at com.tencent.converter.service.PDFBox.textWatermark(PDFBox.java:68) ~[classes!/:0.0.1-SNAPSHOT]
PDFont font = PDType0Font.load(doc, new FileInputStream("/usr/local/services/converter-1.0/lib/STFANGSO.TTF"), false);
And I tried some fonts that support Chinese, all have the same problem

I found a solution to the problem that works for me.
启动服务时 强制指定编码
java -Dfile.encoding=utf-8 -jar

Related

Arial font not working on PDF file on ubuntu

I have a PDF which shows properly on the browser but some text is not showing on the PDF viewer on on UBUNTU, I checked the fonts of the pdf and it return
Syntax Error: non-embedded font using identity encoding: Arial-BoldMT
Syntax Error: non-embedded font using identity encoding: ArialMT
I tried to add font substitute but it is not working.
The actual text is
Benefits (After 90 Days Full Time)
but it shows like following
Benefits (After 90 Days)XOO7LPH)
I have installed arial font on ubuntu also but its still not working.
Please help.
UPDATE : The file is showing properly on adobe pdf viewer and browsers but not on ubuntu.
It appears to be a bug in Firefox.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1766039.
The same bug was also reported in pdf.js github https://github.com/mozilla/pdf.js/issues/15317

Chinese characters are not displayed correctly when running quarkus directly in IDEA

Chinese characters are not displayed correctly when running quarkus directly in IDEA.
IDEA version : IntelliJ IDEA 2021.3 (Ultimate Edition)
Quarkus version : 2.5.4.Final
Quarkus Tools for IntelliJ version : 1.9.0.185
JDK version : graalvm-jdk17
maven version : 3.8.4
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
When I start quarkus directly with idea's run function, no matter what my file.encoding parameter is set to UTF-8 or GBK, it does not display Chinese characters correctly, as shown in the following image :
UTF-8 :
GBK :
But hen I run quarkus:dev in the terminal, the Chinese characters are displayed correctly, as shown in the picture :
I don't know the cause of this problem is the IDEA or the quarkus tool or the quarkus framework.
I tried to attach more information :
System.out.println(System.getProperty("file.encoding"));//GBK
System.out.println(Charset.defaultCharset());//GBK
System.out.println("注意身体,适度看漫");//Right
//注意身体,适度看漫
logger.info(new String("注意身体,适度看漫".getBytes(StandardCharsets.UTF_8)));//Right
//2021-12-30 19:53:49,920 INFO [io.git.jia.fin.run.ComicRunner] (Quarkus Main Thread) 注意身体,适度看漫
logger.info("注意身体,适度看漫");//Error
//2021-12-30 19:53:49,920 INFO [io.git.jia.fin.run.ComicRunner] (Quarkus Main Thread) ???????,??????
logger.info(new String("注意身体,适度看漫".getBytes("GBK")));//Error
//2021-12-30 19:53:49,920 INFO [io.git.jia.fin.run.ComicRunner] (Quarkus Main Thread) ???????,??????
Maybe you can try:
Step1. use "JAVA_TOOL_OPTIONS" key and set "-Dfile.encoding=UTF-8" value in environment variables.
Step2. make sure your file encoding already set "UTF-8", from Settings | Editor | File Encodings
hope this can help you :)
Choose the font family used in your "console configuration" which supports Chinese characters, from File menu and Settings | Editor | Font

Cleanthesis TeX Theme wont create pdf

Im trying to build a (the thesis-example.tex) PDF with the cleanthesis theme (http://cleanthesis.der-ric.de/) and it wont work
The last failure is:
! pdfTeX error (font expansion): auto expansion is only possible with scalable
fonts.
\AtBegShi#Output ...ipout \box \AtBeginShipoutBox
\fi \fi
l.107 \cleardoublepage
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on thesis-example.log.
Im currently on a Fed26 System with 5928 installed texlive packages.
(dnf install texlive-scheme-full, dnf install texlive-*)
If i try this with a complete stock Ubuntu 16.04 and texlive-publisher and texlive-full packages it works. So i guess there is no missing package.
I you need specific parts of thesis-example.log, let me know i cant paste it because its too large
So i installed a clean Fed26 and loaded all texlive packages i had on the main pc. I compared /etc/texlive/web2c/updmap.cfg and i saw that my updmap.cfg was currupted.
I copied the working updmap.cfg to my main system and did a "updmap-sys --force" and now it works

How installshield searches and create jvm path hint file?

I'm using installshield to install a product, it will first read the is:javahome tag to specify and verify the jre position, if not set then read a tmp file /tmp/istemp2223070045253/xxx_linux_150.jvm to install with. Here is content of this jvm hint file:
DESC: IBM Java Runtime Environment (JRE) 1.5.0 for Linux
JVM_EXE: bin/java
SKIP_PATH_SEARCH: true
CLASSPATH: "-cp "
CLASSPATH_SEPARATOR: :
SYSTEM: "-D"
SYSTEM_SEPARATOR: =
INITIAL_HEAP_SIZE: "-Xms"
MAXIMUM_HEAP_SIZE: "-Xmx"
JVM_PROPERTIES:
"java.vendor=IBM..."
"java.version=1.5.0..."
/:
SET_ENV_FOR_WIZARD:
JAVA2D_USEAWTFONTS=0
/:
PATH_HINT:
was/linux/java
../linux
linux/java
/:
SEARCH_ALL: 0
JVM_HOME:/update/xxx/was/linux/java/
I want to know how this jvm file works and how the path_hint generated? Is there any doc that I can refer? Thanks

How to use 'Consolas' as the coding font

I would like to change the font for code edition in a Squeak 4.3 image on windows OS, to use if possible the consolas font.
I found nothing in the preferences browser to do that easily. That SO question looked perfect, but none of the answers work in my case.
For example on the line
font := LogicalFont familyName: 'Bitmap DejaVu Sans' pointSize: 10.
It fails on the LogicalFont: I get the popup that allows to fix a missing class/variable.
Unknown variable: LogicalFont please correct, or cancel: [...]
Is that solution not suitable for Squeak 4.3, or am I missing some package?
EDIT: as often, I am finding some answer elements after the question has been posted on SO:
I found nothing in the preferences browser to do that easily.
Because the setting is not accessible via the Preference Browser, but via the World menu -> Appearance -> System fonts -> code font.
But I only see a handful of fonts available (beside ComicSans and BitstreamVera), but no Consolas. I do have the preference Offer native fonts enabled, though...
Second Edit: given the answer of Igor Stasenko, I found on SqueakSource a mention of FreeTypePlus that seems the most recent (not often easy for a beginner to find out how to install new software on Squeak, also it seems that Squeak has slowed down since 2006/2007 and some items mentioned in the Swiki are down now...)
So I added on Monticello
MCHttpRepository
location: 'http://www.squeaksource.com/FreeTypePlus'
user: ''
password: ''
And installed FreeType, FreeTypeSubPixelAntiAliasing and PinesoftEnhancementsForFreetype. Now I can see my ttf system fonts...
AFAIK, Squeak doesn't includes Freetype support by default.
You may try Pharo, where Freetype is included by default. http://www.pharo-project.org/home
Or you can try to install Freetype package in Squeak & download freetype plugin for VM.