我用您的代码运行了一遍还是不行
public class classTestMain {
public static void main(String[] args) throws Exception {
test();
}
public static void test() throws Exception {
String s = "?text=Hello, world! \r\n" +
"\tfont_style=bold\r\n" +
"\tfont_size=24\r\n" +
"\r\n" +
"#你今天你今天怎么样子? \r\n" +
"\t()Pretty good, thanks! () I won't respond until I see my lawyer.\r\n" +
"\t()很好你很好很好挖到! () I won't respond until I see my lawyer.\r\n" +
"#How are you doing today? \r\n" +
"\t()Pretty good, thanks! ()I won’t respond until I see my lawyer.\r\n";
Files.write(Paths.get("d:\\测试 - utf8.txt"), s.getBytes(StandardCharsets.UTF_8));
OmrEngine engine = new OmrEngine();
GlobalPageSettings pageSettings = new GlobalPageSettings();
pageSettings.FontFamily = "SimSun";
pageSettings.FontSize = 16;
GenerationResult res = engine.generateTemplate("d:\\测试 - utf8.txt", pageSettings);
res.save(String.valueOf(Paths.get("d:\\")), "template-java");
}
}
template-java.jpg (205.4 KB)
package com.zysofts.tixue.zip.vo;
import com.aspose.omr.*;
import com.aspose.omr.System.Text.Encoding;
import com.aspose.words.FontSettings;
import net.coobird.thumbnailator.tasks.io.FileImageSink;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
/**
-
ClassName: classTestMain
-
@author LEGION
-
@since JDK 21
*/
public class classTestMain {public static void main(String[] args) throws Exception {
test();
}
public static void test() throws Exception {String s = "?text=Hello, world! \r\n" + "\tfont_style=bold\r\n" + "\tfont_size=24\r\n" + "\r\n" + "#你今天你今天怎么样子? \r\n" + "\t()Pretty good, thanks! () I won't respond until I see my lawyer.\r\n" + "\t()很好你很好很好挖到! () I won't respond until I see my lawyer.\r\n" + "#How are you doing today? \r\n" + "\t()Pretty good, thanks! ()I won’t respond until I see my lawyer.\r\n"; Files.write(Paths.get("d:\\测试 - utf8.txt"), s.getBytes(StandardCharsets.UTF_8)); OmrEngine engine = new OmrEngine(); GlobalPageSettings pageSettings = new GlobalPageSettings(); pageSettings.FontFamily = "SimSun-ExtG"; pageSettings.FontSize = 16; GenerationResult res = engine.generateTemplate("d:\\测试 - utf8.txt", pageSettings); res.save(String.valueOf(Paths.get("d:\\")), "template-java");
}
}
就标题乱码了
我也测试了“SimSun-ExtG”字体,所有字符似乎都显示正常。
为了解决这个问题,请分享更多详细信息:
- 生成的 .txt 文件是否存在差异?所有符号是否都显示正常?能否分享一个包含模板配置的文件:
d:\\测试 - utf8.txt
- 为了正确复现问题,请分享所使用的 JDK/操作系统/Aspose.OMR 版本。
谢谢!
===============================================================================
I have tested “SimSun-ExtG” font as well, all characters appear to be displayed properly.
To resolve this issue, please share additional details:
- Is there discrepancies in generated .txt file? Does all symbols displayed properly? Can you share a file containing template config:
d:\\测试 - utf8.txt
- To replicate issue properly, please share versions of JDK/operating system/Aspose.OMR that is used.
Thank you!
操作系统 windows 10
jdk 21
omr 24.5
我用您发给我的文件生成的也是乱码的
package com.tixue.aspose.omr;
import com.aspose.omr.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
/**
-
ClassName: HelloWord
-
@author LEGION
-
@since JDK 21
*/
public class HelloWord {public static void main(String[] args) throws Exception {
test();
}
public static void test() throws Exception {String s = "?text=Hello, world! \r\n" + "\tfont_style=bold\r\n" + "\tfont_size=24\r\n" + "\r\n" + "#你今天你今天怎么子我的我的我的我的我的? \r\n" + "\t()Pretty good, thanks! () I won't respond until I see my lawyer.\r\n" + "\t()你今天你今天怎么子! () I won't respond until I see my lawyer.\r\n" + "#How are you doing today? \r\n" + "\t()Pretty good, thanks! ()I won’t respond until I see my lawyer.\r\n"; Files.write(Paths.get("d:\\测试 - utf8.txt"), s.getBytes(StandardCharsets.UTF_8)); OmrEngine engine = new OmrEngine(); GlobalPageSettings pageSettings = new GlobalPageSettings();
// pageSettings.FontFamily = “SimSun-ExtB”;
// pageSettings.FontSize = 16;
GenerationResult res = engine.generateTemplate("d:\\测试 - utf8.txt", pageSettings);
res.save(String.valueOf(Paths.get("d:\\")), "template-java");
}
}
这个就不乱码 之前发的那个乱码
public static void main(String[] args) throws Exception {
test();
test2();
}
public static void test() throws Exception {
String s = "?text=Hello, world! \r\n" +
"\tfont_style=bold\r\n" +
"\tfont_size=24\r\n" +
"\r\n" +
"#你今天你今天怎么子我的我的我的我的我的? \r\n" +
"\t()Pretty good, thanks! () I won't respond until I see my lawyer.\r\n" +
"\t()你今天你今天怎么子! () I won't respond until I see my lawyer.\r\n" +
"#How are you doing today? \r\n" +
"\t()Pretty good, thanks! ()I won’t respond until I see my lawyer.\r\n";
Files.write(Paths.get("d:\\测试 - utf8.txt"), s.getBytes(StandardCharsets.UTF_8));
OmrEngine engine = new OmrEngine();
GlobalPageSettings pageSettings = new GlobalPageSettings();
// pageSettings.FontFamily = “SimSun-ExtB”;
// pageSettings.FontSize = 16;
GenerationResult res = engine.generateTemplate("d:\\测试 - utf8.txt", pageSettings);
BufferedImage templateImage = res.getTemplateImage();
File outputFile = new File("d:\\template-java1.png");
ImageIO.write(templateImage, "png", outputFile);
System.out.println("Image saved successfully to: " + outputFile.getAbsolutePath());
res.save(String.valueOf(Paths.get("d:\\")), "template-java");
}
public static void test2() throws Exception {
String s = "?text=Hello, world! \r\n" +
"\tfont_style=bold\r\n" +
"\tfont_size=24\r\n" +
"\r\n" +
"#你今天你今天怎么子我的我的我的我的我的? \r\n" +
"\t()Pretty good, thanks! () I won't respond until I see my lawyer.\r\n" +
"\t()你今天你今天怎么样子! () I won't respond until I see my lawyer.\r\n" +
"#How are you doing today? \r\n" +
"\t()Pretty good, thanks! ()I won’t respond until I see my lawyer.\r\n";
Files.write(Paths.get("d:\\测试 - utf8.txt"), s.getBytes(StandardCharsets.UTF_8));
OmrEngine engine = new OmrEngine();
GlobalPageSettings pageSettings = new GlobalPageSettings();
// pageSettings.FontFamily = “SimSun-ExtB”;
// pageSettings.FontSize = 16;
GenerationResult res = engine.generateTemplate("d:\\测试 - utf8.txt", pageSettings);
BufferedImage templateImage = res.getTemplateImage();
res.save(String.valueOf(Paths.get("d:\\")), "template-java1");
}
test2()就中文乱码 是方框
package com.tixue.aspose.omr;
import com.aspose.omr.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import javax.imageio.ImageIO;
import java.io.File;
public class Main {
public static void main(String[] args) throws Exception {
test();
test2();
}
public static void test() throws Exception {
String s = "?text=Hello, world! \r\n" +
"\tfont_style=bold\r\n" +
"\tfont_size=24\r\n" +
"\r\n" +
"#你今天你今天怎么子我的我的我的我的我的? \r\n" +
"\t()Pretty good, thanks! () I won't respond until I see my lawyer.\r\n" +
"\t()你今天你今天怎么子! () I won't respond until I see my lawyer.\r\n" +
"#How are you doing today? \r\n" +
"\t()Pretty good, thanks! ()I won’t respond until I see my lawyer.\r\n";
Files.write(Paths.get("d:\\测试 - utf8.txt"), s.getBytes(StandardCharsets.UTF_8));
OmrEngine engine = new OmrEngine();
GlobalPageSettings pageSettings = new GlobalPageSettings();
pageSettings.FontFamily = "SimSun-ExtG";
GenerationResult res = engine.generateTemplate("d:\\测试 - utf8.txt", pageSettings);
BufferedImage templateImage = res.getTemplateImage();
try {
File outputFile = new File("d:\\template-java1.png");
ImageIO.write(templateImage, "png", outputFile);
System.out.println("Image saved successfully to: " + outputFile.getAbsolutePath());
} catch (IOException e) {
System.err.println("Failed to save image: " + e.getMessage());
}
}
public static void test2() throws Exception {
try {
String s = "?text=Hello, world! \r\n" +
"\tfont_style=bold\r\n" +
"\tfont_size=24\r\n" +
"\r\n" +
"#你今天你今天怎么子我的我的我的我的我的? \r\n" +
"\t()Pretty good, thanks! () I won't respond until I see my lawyer.\r\n" +
"\t()你今天你今天怎么样子! () I won't respond until I see my lawyer.\r\n" +
"#How are you doing today? \r\n" +
"\t()Pretty good, thanks! ()I won’t respond until I see my lawyer.\r\n";
Files.write(Paths.get("d:\\测试 - utf8-test2.txt"), s.getBytes(StandardCharsets.UTF_8));
OmrEngine engine = new OmrEngine();
GlobalPageSettings pageSettings = new GlobalPageSettings();
pageSettings.FontFamily = "SimSun-ExtG"; // 或 "Microsoft YaHei"
GenerationResult res = engine.generateTemplate("d:\\测试 - utf8-test2.txt", pageSettings);
BufferedImage templateImage = res.getTemplateImage();
File outputFile = new File("d:\\template-java1-test2.png");
ImageIO.write(templateImage, "png", outputFile);
System.out.println("Image saved successfully to: " + outputFile.getAbsolutePath());
System.out.println("-------------------------");
String errorMessage = res.getErrorMessage();
System.out.println(errorMessage);
System.out.println(res.getTemplate());
System.out.println(res.getErrorCode());
for (String warning : res.getWarnings()) {
System.out.println(warning);
}
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
e.printStackTrace();
}
}
}
我已经在 Windows 10 和 JDK 21 下使用 OMR 24.5 版本调试了该库。
很遗憾,我未能检测到所描述的问题。
您能否分享以下 Java 代码的输出:
import java.awt.*;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fontFamilies = ge.getAvailableFontFamilyNames();
for (String ff : fontFamilies) {
System.out.println(ff);
}
它会在控制台中输出所有 JDK 可用字体的列表。
您能否分享相关信息 - 这个问题在其他 JDK 中仍然存在吗?
谢谢!
===================================================================
I have debugged the library under Windows 10, JDK 21 using OMR version 24.5.
Unfortunately, I was unable to detect described issues.
Can you share output from the next Java code:
import java.awt.*;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fontFamilies = ge.getAvailableFontFamilyNames();
for (String ff : fontFamilies) {
System.out.println(ff);
}
It would output into console a list of all available to JDK fonts.
Can you share information - does this issue persist with other JDK’s?
Thank you!
Agency FB
Algerian
Arial
Arial Black
Arial Narrow
Arial Rounded MT Bold
Arvo
Bahnschrift
Barlow Condensed
Barrio
Baskerville Old Face
Bauhaus 93
Bell MT
Berlin Sans FB
Berlin Sans FB Demi
Bernard MT Condensed
Blackadder ITC
Bodoni MT
Bodoni MT Black
Bodoni MT Condensed
Bodoni MT Poster Compressed
Book Antiqua
Bookman Old Style
Bookshelf Symbol 7
Bradley Hand ITC
Britannic Bold
Broadway
Brush Script MT
Bubblegum Sans
Cabin Sketch
Calibri
Calibri Light
Californian FB
Calisto MT
Cambria
Cambria Math
Candara
Candara Light
Cascadia Code
Cascadia Mono
Castellar
Centaur
Century
Century Gothic
Century Schoolbook
Chiller
Colonna MT
Comfortaa
Comic Sans MS
Consolas
Constantia
Cooper Black
Copperplate Gothic Bold
Copperplate Gothic Light
Corbel
Corbel Light
Courier New
Curlz MT
DejaVu Math TeX Gyre
DejaVu Sans Mono
Delius
Dialog
DialogInput
DIN Next LT Pro
DIN Next LT Pro Light
DIN Next LT Pro Medium
Dosis
Droid Serif
Dubai
Dubai Light
Dubai Medium
Ebrima
Edwardian Script ITC
Elephant
Engravers MT
Eras Bold ITC
Eras Demi ITC
Eras Light ITC
Eras Medium ITC
Felix Titling
Footlight MT Light
Forte
Franklin Gothic Book
Franklin Gothic Demi
Franklin Gothic Demi Cond
Franklin Gothic Heavy
Franklin Gothic Medium
Franklin Gothic Medium Cond
Fredericka the Great
Fredoka One
Freestyle Script
French Script MT
Gabriola
Gadugi
Garamond
Georgia
Gigi
Gill Sans MT
Gill Sans MT Condensed
Gill Sans MT Ext Condensed Bold
Gill Sans Ultra Bold
Gill Sans Ultra Bold Condensed
Gloucester MT Extra Condensed
Goudy Old Style
Goudy Stout
Haettenschweiler
Harlow Solid Italic
Harrington
High Tower Text
HoloLens MDL2 Assets
Impact
Imprint MT Shadow
Indie Flower
Informal Roman
Ink Free
Javanese Text
Jokerman
Juice ITC
Julius Sans One
Kristen ITC
Kunstler Script
Leelawadee
Leelawadee UI
Leelawadee UI Semilight
Lobster
Lucida Bright
Lucida Calligraphy
Lucida Console
Lucida Fax
Lucida Handwriting
Lucida Sans
Lucida Sans Typewriter
Lucida Sans Unicode
Magneto
Maiandra GD
Malgun Gothic
Malgun Gothic Semilight
Marlett
Matura MT Script Capitals
Megrim
Microsoft Himalaya
Microsoft JhengHei UI
Microsoft JhengHei UI Light
Microsoft New Tai Lue
Microsoft PhagsPa
Microsoft Sans Serif
Microsoft Tai Le
Microsoft Uighur
Microsoft YaHei UI
Microsoft YaHei UI Light
Microsoft Yi Baiti
Mistral
Modern No. 20
Mongolian Baiti
Monospaced
Monoton
Monotype Corsiva
MS Gothic
MS Outlook
MS PGothic
MS Reference Sans Serif
MS Reference Specialty
MS UI Gothic
MT Extra
MV Boli
Myanmar Text
Nanum Pen
Niagara Engraved
Niagara Solid
Nirmala UI
Nirmala UI Semilight
Noto Sans SC
NumberOnly
OCR A Extended
Old English Text MT
Onyx
Open Sans
Open Sans Semibold
Palace Script MT
Palatino Linotype
Pangolin
Papyrus
Parchment
Perpetua
Perpetua Titling MT
Playbill
Poiret One
Poor Richard
Pristina
Rage Italic
Raleway
Ravie
Roboto
Roboto Condensed
Roboto Slab
Rockwell
Rockwell Condensed
Rockwell Extra Bold
SansSerif
Script MT Bold
Segoe MDL2 Assets
Segoe Print
Segoe Script
Segoe UI
Segoe UI Black
Segoe UI Emoji
Segoe UI Historic
Segoe UI Light
Segoe UI Semibold
Segoe UI Semilight
Segoe UI Symbol
Serif
Shadows Into Light
Showcard Gothic
SimSun-ExtB
SimSun-ExtG
Sitka Banner
Sitka Display
Sitka Heading
Sitka Small
Sitka Subheading
Sitka Text
Snap ITC
Source Sans Pro
Source Sans Pro Black
Source Sans Pro Light
Source Sans Pro SemiBold
Stencil
Sylfaen
Symbol
Tahoma
Tempus Sans ITC
Times New Roman
Trebuchet MS
Tw Cen MT
Tw Cen MT Condensed
Tw Cen MT Condensed Extra Bold
Vast Shadow
Verdana
Viner Hand ITC
Vivaldi
Vladimir Script
Webdings
Wide Latin
Wingdings
Wingdings 2
Wingdings 3
Yu Gothic
Yu Gothic Light
Yu Gothic Medium
Yu Gothic UI
Yu Gothic UI Light
Yu Gothic UI Semibold
Yu Gothic UI Semilight
Zilla Slab
仿宋
华文中宋
华文仿宋
华文宋体
华文彩云
华文新魏
华文楷体
华文琥珀
华文细黑
华文行楷
华文隶书
宋体
幼圆
微軟正黑體
微軟正黑體 Light
微软雅黑
微软雅黑 Light
新宋体
新細明體-ExtB
方正兰亭超细黑简体
方正姚体
方正粗黑宋简体
方正舒体
楷体
汉仪中黑 197
等线
等线 Light
細明體-ExtB
細明體_HKSCS-ExtB
隶书
黑体
我注意到这些字体使用了中文象形文字。您能分享一下使用象形文字指定字体名称的结果吗?
=========================================================================
I have noticed, that these fonts using Chinese hieroglyphs. Can you share the result of specifying font name with hieroglyphs as well?
可以微信沟通吗 我感觉微信更方便
我在其他电脑上试了也是乱码
这是我的所有字体
很遗憾,除了这个论坛之外,我无法提供其他支持。
请谅解。
感谢您提供的字体 - 我会测试它们并在这里发布结果。
================================================================
Unfortunately, I am unable to provide support other than this forum.
Please understand.
Thank you for the Fonts - I will test them and post results here.
生成的模版 选择题的气泡能自定义形状吗
不,很遗憾,Java 版 OMR 库目前不支持此选项。
不过,有一个 GUI 客户端 具有离线功能,可用于在现有图像上标记气泡。其工作结果是 .omr 文件和带有参考点的模板图像。该图像的识别与 Aspose OMR for Java 库完全兼容。
OMR Cloud 客户端通过 SID 和 KEY 访问。对于离线功能,可以使用 36 位和 32 位符号的任意组合。
OMR-client.png (99.0 KB)
==========================================================
No, unfortunately, Java version of OMR library does not have this option yet.
But, there is a GUI client with offline features, that can be used to mark up bubbles on an existing image. The result of its work is .omr file and template image with reference points. Recognition of this image is fully compatible with Aspose OMR for Java library.
OMR Cloud client is accessed through SID and KEY. For offline features, one can use just any combination of 36 and 32 symbols.
OMR-client.png (99.0 KB)
Hello, @171111141999
I checked fonts you supplied and can confirm, that “SimSun-ExtB” are bit-perfect copy of my fonts and cannot be the source of the problem.
I have prepared a sample maven Java project, that can be run in IntelliJ IDEA. In case you are using different IDE - please run .java file and share results.
OMRJAVA-108-example.zip (6.2 KB)
Thank you!