https://issues.apache.org/bugzilla/show_bug.cgi?id=52164
Bug #: 52164 Summary: Problems with accents and master page font Product: POI Version: 3.8-dev Platform: PC OS/Version: Windows XP Status: NEW Severity: critical Priority: P2 Component: HSLF AssignedTo: dev@poi.apache.org ReportedBy: nbodi...@free.fr Classification: Unclassified When we create a slide with some text inside, if the font of the TextShape is different from the "default" font (of the Master Page) then : - all characters use the font specified in the TextShape (This is CORRECT) BUT - accents such as é à è ù î use the default font and it is not possible to change it. a) I tried to use unicode encoding like : \u00e9 instead of é but the problem remains b) I tried to set the value as HTML then encode é but this just displays the é and is not working either. c) I tried to FORCE the font of the RichText to the default font, this works and now the strings with accent is fine on screen (with the other font) BUT this is not usable, since the size of the TextShape changes and I have text overlapping or gaps between text d) I tried to change the default font of the master page with the API but it does not seem to be possible to this. e) Finally the only workaround which works is to test the default font and the TextShape font and if they differ to call : public static String removeAccents(String s) { if (s != null && s.length() > 0) { s = s.replaceAll("[èéêë]","e"); s = s.replaceAll("[ûù]","u"); s = s.replaceAll("[ïî]","i"); s = s.replaceAll("[àâ]","a"); s = s.replaceAll("Ô","o"); s = s.replaceAll("[ÈÉÊË]","E"); s = s.replaceAll("[ÛÙ]","U"); s = s.replaceAll("[ÏÎ]","I"); s = s.replaceAll("[ÀÂ]","A"); s = s.replaceAll("Ô","O"); } return s; } and all accents are gone ... The text is correctly displayed but the end users will complain for missing accents... Until a fix for this issue. *** Code example found over the internet :assuming test.ppt is using Arial as default font and we have some text box using times new roman. HSLFSlideShow hslfsh = new HSLFSlideShow("template/test.ppt"); SlideShow ppt = new SlideShow(hslfsh); Slide slide[] = ppt.getSlides(); for(int i = 0 ; i < slide.length ; i++) { Slide curSlide = slide[i]; Shape sh[] = curSlide.getShapes(); for(int j = 0; j < sh.length ; j++ ) { Shape curSh = sh[j]; TextBox tb = new TextBox(); tb.setAnchor(curSh.getAnchor()); tb.setText("Helloworld é è ë ê à ö ï î ô ü û"); TextBox shape = (TextBox)curSh; RichTextRun rt = shape.getTextRun().getRichTextRuns()[0]; RichTextRun newRt = tb.getTextRun().getRichTextRuns()[0]; // style copy newRt.setAlignment(rt.getAlignment()); newRt.setBold(rt.isBold()); newRt.setFontColor(Color.black); newRt.setFontName(rt.getFontName()); newRt.setFontSize(rt.getFontSize()); newRt.setItalic(rt.isItalic()); newRt.setUnderlined(rt.isUnderlined()); // remove old shape curSlide.removeShape(shape); curSlide.addShape(tb); } } -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org