How to config Font substitution in poppler - poppler

When convert pdf page to image, if a Font is not embedded in the input pdf, default Font substitution (usually Arial) is used. However, I want to change the default font.
There is a description here but it is too few information. I don't know how to create and where to put the config file.
OS: Ubuntu 18.04

The page you mentioned saved me, thanks!
Here is how:
As they indicate, what is needed is to configure fontconfig. I can't be sure for Ubuntu, but for Debian this means creating or editing this file :
/etc/fonts/local.conf
For the font substitution, you just need to include something like this example:
<alias>
<family>Helvetica</family>
<accept><family>Nimbus Sans L</family></accept>
</alias>
Where the Helvetica family would be substituted by the 'Nimbus Sans L' family.
To check that it works, you may use a PDF file containing e.g. Helvetica, and type:
pdffonts -subst <yourfile>.pdf
This will list the fonts substitutions. In my case, it worked just fine, with poppler now doing the right substitution.

For Fedora, I created ~/.config/fontconfig/fonts.conf with following content:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<test name="family">
<string>Helvetica</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>Liberation Sans</string>
</edit>
</match>
</fontconfig>
It worked fine, tested with fc-match Helvetica and pdffonts -subst <yourfile>.pdf
I recommend the arch linux wiki for more font configuration info.

Related

configuring Java 9 in JNLP

The docs say I can configure the Java 9 platform in JNLP like this:
<j2se version="9" ... />
However if I do so and try to run it using Java 9.0.4 I get a warning saying the requested Java version (9) is not installed. My code:
<j2se version="9" java-vm-args="-Xmx1g" href="http://java.sun.com/products/autodl/j2se"/>
If I do this instead, there is no such popup:
<j2se version="9.*" ... />
But I cannot find such a "*" wildcard in the specs. What is going on?
I found out what's wrong. My example was incomplete, because I did not mention the href attribute I was using in the j2se element.
Solution: In contrast to versions, platforms must be specified without href attributes.
If a platform version is specified (that is, no href attribute is
provided)
https://docs.oracle.com/javase/9/deploy/jnlp-file-syntax.htm
Fixed element (for the example in the question):
<j2se version="9" java-vm-args="-Xmx1g"/>

Validating issue: Unknown Tag/Undefined attribute name warnings in Eclipe

The following code presents validation issues for me in Eclipse 4.4.2. This is located in a JSP file.
<svg version="1.1" class="..." xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="..." y="..." width="..x" height="..." viewBox="..."
enable-background="..." xml:space="...">
<g>
<polygon fill="#FFFFFF" points="..."></polygon>
<polygon fill="#FFFFFF" points="..."></polygon>
</g>
</svg>
This code produces the following warnings:
"Undefined attribute name (attribute-name)" for every attribute attached to the svg element
"Unknown tag (tag-name)" for the g and polygon tags.
I ran this through an online validator that supports HTML5/SVG1.1, and it told me there were 0 validation issues.
Any ideas why this could be happening? I'm aware that I can choose to ignore the validation issues through Window > Preferences > Validation, but I would prefer to find a way to get Eclipse to actually recognize these tags/attributes because they work just fine.
The namespace http://www.w3.org/2000/svg does not seem to be recognised by your eclipse installation. Try either of:
Adding the namespace to your XML catalog (in Window > Preferences), including the schema for svg, or
Specifying the schema inline, as attributes of the svg element:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.w3.org/TR/2002/WD-SVG11-20020108/SVG.xsd"
(or wherever your local copy of the schema is)

Font Awesome NuGet Package 3.2.1

Is there something wrong with the Font Awesome 3.2.1 NuGet package? When I upgraded from 3.1.1 to 3.2.1 all the fonts stopped displaying. If I link directly to Font Awesome via BootstrapCDN (http://www.bootstrapcdn.com/) everything works fine.
The problem is caused by incorrect relative paths in the CSS. To correct this, update the following files like so (this assumes that the font directory is a subdirectory of where your Font Awesome CSS files are located):
font-awesome.css, line 28-34:
#font-face {
font-family: 'FontAwesome';
src: url('font/fontawesome-webfont.eot?v=3.2.1');
src: url('font/fontawesome-webfont.eot?#iefix&v=3.2.1') format('embedded-opentype'), url('font/fontawesome-webfont.woff?v=3.2.1') format('woff'), url('font/fontawesome-webfont.ttf?v=3.2.1') format('truetype'), url('font/fontawesome-webfont.svg#fontawesomeregular?v=3.2.1') format('svg');
font-weight: normal;
font-style: normal;
}
font-awesome.min.css, line 1:
#font-face{font-family:'FontAwesome';src:url('font/fontawesome-webfont.eot?v=3.2.1');src:url('font/fontawesome-webfont.eot?#iefix&v=3.2.1') format('embedded-opentype'),url('font/fontawesome-webfont.woff?v=3.2.1') format('woff'),url('font/fontawesome-webfont.ttf?v=3.2.1') format('truetype'),url('font/fontawesome-webfont.svg#fontawesomeregular?v=3.2.1') format('svg');font-weight:normal;font-style:normal;}[class^="icon-"],[class*=" icon-"]{font-family:FontAwesome;font-weight:normal;font-style:normal;text-decoration:inherit;-webkit-font-smoothing:antialiased;*margin-right:.3em;}
Of course, this defeats the point of using NuGet packages, but consider it a temporary workaround until the package is fixed. It probably doesn't help that there are two FontAwesome NuGet packages to choose from, but I would assume once fixed, the package created by Dave Gandy will supercede the one created by JiveCode.
It's likely because the import path in the font-awesome CSS file is wrong for the way the NuGet package inserts the files. Problem I'm having is it's dumped all the files into the same directory but the import path assumes the CSS files are in their own directory within the directory that the fonts directory is in.
I'm feeling fairly sure it is indeed an issue with the package.

Can't make Ant write proper version info with unicode (c) character

After upgrading ant from 1.6 to 1.8.3 version info resources of Windows .dlls that are built with Ant became corrupted.
Previously this value was properly saved to the version-info resource:
product.copyright=\u00a9 Copyright 20xx-20xx yyyyyyyyyy \u2122 (so (c) and TM symbols were properly displayed).
After upgrading Ant default encoding was changed to UTF-8 which is expected, but currently Copyright string looks like this:
© Copyright 20xx-20xx yyyyyy ™
This is not a console issue - I checked with hex editor and File Properties dialog - both display it incorrectly.
Looking at file's hexdump I see that following (obviously incorrect) mapping occurs
\u00a9 -> 0x00c2 0x00a9
\u2122 -> 0x00e2 0x201e 0x00a2
The problem here is that Ant encodes UTF-8 bytes (not Unicode string) into 16-bit characters and writes it to version-info.
Although this looks like a bug in ant, I would ask if anyone managed to find any workarounds for this or similar problems.
Here are some snippets from the script:
Project properties file:
...
product.copyright=(c) Copyright 2005-2012 Clarabridge
....
Files included into build.xml:
<versioninfo id="current-version" if="is-windows"
fileversion="${product.version}"
productversion="${product.version}"
compatibilityversion="1"
legalcopyright="${product.copyright}"
companyname="${product.company}"
filedescription="${ant.project.name}"
productname="${ant.project.name}"
/>
...
<cc objdir="${target.dir}/${target.platform}/obj"
outfile="${target.dir}/${target.platform}/${ant.project.name}"
subsystem="other"
failonerror="true"
incremental="false"
outtype="shared"
runtime="dynamic"
>
<versioninfo refid="current-version" />
<compiler refid="compiler-shared-${target.platform}" />
<compiler refid="rc-compiler" />
<linker extends="linker-${target.platform}">
<libset dir="${target.dir}/${target.platform}/lib" libs="${lib.list}" />
</linker>
<fileset dir="${src.dir}" casesensitive="false">
<include name="*.cpp"/>
</fileset>
</cc>
Your bug is that something is misinterpreting the UTF-8 characters as 8-bit ones!!!
BTW, Java doesn’t use 16-bit characters; that would be UCS-2. Java uses UTF-16, which is just as much a variable-width encoding as UTF-8 is. Distressing how many Java programmers screw this up!
UTF-8 has 8-bit code units where UTF-16 has 16-bit code units; neither one supports an “8-bit character” or a “16-bit character”. If you catch yourself writing code that thinks they do, you’ve just written buggy code.
Your output is the result of erroneously displaying UTF-8 as though it were in Latin1, which does use 8-bit characters. You, however, do not.

ANT Javac and special characters

I have an ANT task defined like so:
<javac source="1.5" target="1.5" srcdir="${src.dir}" destdir="${classes.dir}" deprecation="on" debug="on" classpathref="classpath" fork="true" memoryMaximumSize="512m" encoding="UTF-8">
<include name="${app.directory}/**/*.java"/>
</javac>
This works fine, but when I have classes with special characters in their names it gives me the following error:
[iosession] Compiling 131 source files to /C24/PUB/io-stds/trunk/standards/GSIT/build/test/deployment/build/classes
[iosession] javac: file not found: /C24/PUB/io-stds/trunk/standards/GSIT/build/test/deployment/src/java/biz/c24/io/minos/AléaChiffréClass.java
[iosession] Usage: javac <options> <source files>
[iosession] use -help for a list of possible options
[iosession] Target compile finished
[iosession]
[iosession] Building unsuccessful 2 seconds
When I remove the "fork=true" it works, but then it ignores the "memoryMaximumSize" setting. I also tried the nested approach, but to no avail.
Any ideas?
It's perhaps not the answer you expect but my advice would be to remove all non-ascii letters from the names of methods and classes. I'm French-speaking too, and I've never seen any company, even in France and using French as its development language, accept accented letters in class names and methods. It's just not good practice, simply because it would be very hard for a non French developer, without accents on his keyboard, to use these classes and methods.
If you use a good IDE, it should allow you to refactor your code easily.
Apache did confirm that the encoding attribute only applies to the file contents and not file names. I reverted back to using fork only when needed and kept encoding="UTF-8".