- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如您所知,许多 ui 组件和开发工具不支持 rtl ,我们可以将其称为 flipping text ,因为结果与示例相同:
左转
سلام salam متن راهنما word
RTL
word متن راهنما salam سلام
有没有办法把这个 LTR 转换成 RTL,我不知道,语言也不重要
实际上我正在寻找一种解决方案来在 RAD Studio Firemonkey 应用程序中完成这项工作,因为您可能知道 firemonkey 应用程序不支持 rtl 它在 rad studio 的路线图中但尚未实现
最佳答案
在 Windows 下,您可以通过 UniScribe API。
我用它把 Unicode 文本转换成一组字形,用于我们的 Open Source PDF writer .
您在 SynPdf.pas 中有源代码示例单元。参见 TPdfWrite.AddUnicodeHexTextUniScribe
方法:
function TPdfWrite.AddUnicodeHexTextUniScribe(PW: PWideChar;
WinAnsiTTF: TPdfFontTrueType; NextLine: boolean; Canvas: TPdfCanvas): boolean;
var L, i,j: integer;
res: HRESULT;
max, count, numSp: integer;
Sp: PScriptPropertiesArray;
W: PWideChar;
items: array of TScriptItem;
level: array of byte;
VisualToLogical: array of integer;
psc: pointer; // opaque Uniscribe font metric cache
complex,R2L: boolean;
complexs: array of byte;
glyphs: array of TScriptVisAttr;
glyphsCount: integer;
OutGlyphs, LogClust: array of word;
procedure Append(i: Integer);
// local procedure used to add glyphs from items[i] to the PDF content stream
var L: integer;
W: PWideChar;
procedure DefaultAppend;
var tmpU: array of WideChar;
begin
SetLength(tmpU,L+1); // we need the text to be ending with #0
move(W^,tmpU[0],L*2);
AddUnicodeHexTextNoUniScribe(pointer(tmpU),WinAnsiTTF,false,Canvas);
end;
begin
L := items[i+1].iCharPos-items[i].iCharPos; // length of this shapeable item
if L=0 then
exit; // nothing to append
W := PW+items[i].iCharPos;
if not GetBit(complexs[0],i) then begin
// not complex items are rendered as fast as possible
DefaultAppend;
exit;
end;
res := ScriptShape(0,psc,W,L,max,@items[i].a,
pointer(OutGlyphs),pointer(LogClust),pointer(glyphs),glyphsCount);
case res of
E_OUTOFMEMORY: begin // max was not big enough (should never happen)
DefaultAppend;
exit;
end;
E_PENDING, USP_E_SCRIPT_NOT_IN_FONT: begin // need HDC and a selected font object
res := ScriptShape(Canvas.FDoc.GetDCWithFont(WinAnsiTTF),
psc,W,L,max,@items[i].a,
pointer(OutGlyphs),pointer(LogClust),pointer(glyphs),glyphsCount);
if res<>0 then begin // we won't change font if necessary, sorry
// we shall implement the complex technic as stated by
// http://msdn.microsoft.com/en-us/library/dd374105(v=VS.85).aspx
DefaultAppend;
exit;
end;
end;
0: ; // success -> will add glyphs just below
else exit;
end;
// add glyphs to the PDF content
// (NextLine has already been handled: not needed here)
AddGlyphs(pointer(OutGlyphs),glyphsCount,Canvas);
end;
begin
result := false; // on UniScribe error, handle as Unicode
// 1. Breaks a Unicode string into individually shapeable items
L := StrLenW(PW)+1; // include last #0
max := L+2; // should be big enough
SetLength(items,max);
count := 0;
if ScriptItemize(PW,L,max,nil,nil,pointer(items),count)<>0 then
exit; // error trying processing Glyph Shaping -> fast return
// 2. guess if requiring glyph shaping or layout
SetLength(complexs,(count shr 3)+1);
ScriptGetProperties(sP,numSp);
complex := false;
R2L := false;
for i := 0 to Count-2 do // don't need Count-1 = Terminator
if fComplex in sP^[items[i].a.eScript and (1 shl 10-1)]^.fFlags then begin
complex := true;
SetBit(complexs[0],i);
end else
if fRTL in items[i].a.fFlags then
R2L := true;
if not complex then begin
// no glyph shaping -> fast append as normal Unicode Text
if R2L then begin
// handle Right To Left but not Complex text
W := pointer(items); // there is enough temp space in items[]
W[L] := #0;
dec(L);
for i := 0 to L do
W[i] := PW[L-i];
AddUnicodeHexTextNoUniScribe(W,WinAnsiTTF,NextLine,Canvas);
result := true; // mark handled here
end;
exit;
end;
// 3. get Visual Order, i.e. how to render the content from left to right
SetLength(level,count);
for i := 0 to Count-1 do
level[i] := items[i].a.s.uBidiLevel;
SetLength(VisualToLogical,count);
if ScriptLayout(Count,pointer(level),pointer(VisualToLogical),nil)<>0 then
exit;
// 4. now we have enough information to start drawing
result := true;
if NextLine then
Canvas.MoveToNextLine; // manual NextLine handling
// 5. add glyphs for all shapeable items
max := (L*3)shr 1+32; // should be big enough - allocate only once
SetLength(glyphs,max);
SetLength(OutGlyphs,max);
SetLength(LogClust,max);
psc := nil; // cached for the same character style used
if Canvas.RightToLeftText then
// append from right to left visual order
for j := Count-2 downto 0 do // Count-2: ignore last ending item
Append(VisualToLogical[j]) else
// append from left to right visual order
for j := 0 to Count-2 do // Count-2: ignore last ending item
Append(VisualToLogical[j]);
end;
当然,这只是在 Windows 下。所以它不能在 Mac OS X 上运行。你必须在 Mac OS X 下使用另一个库...
关于c++ - 将 LTR 转换为 RTL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8910287/
当我尝试将 NotePad++ 的方向更改为 rtl(从右到左)时它看起来像这样: (我写了“测试”)。 请帮助我:) 最佳答案 要使其在 RTL 模式下正确显示,只需拖动窗口以更改其大小。它会自动修
我正在使用 Expanding Search Bar ,但根据我的要求/设计,搜索图标应位于左侧。因此,我修改了代码,将 right 替换为 left,将 float: right 替换为 float
我在 ltr 中的侧导航栏有一个小问题,我通过添加一个按钮来切换和取消切换来使其响应,如果它低于 700 像素,我还使用媒体查询隐藏它并且只显示切换按钮所以用户可以按下它,然后侧边导航将出现,这样他就
我想根据语言对齐 TextView 的内容(对希伯来语、阿拉伯语等使用 gravity=right)我试图找到资源文件夹后缀,例如 layout-ltr 或一些 API 来帮助我设置重力编程,但我找不
我目前拥有以我的语言显示 RTL 的 Galaxy Note 4,每当我运行我的应用程序时,它都会从右到左运行,而应用程序是英语。 我需要某种“强制”应用程序在所有类型的设备(RTL 和 LTR)中成
现在看来所有GUI元素的布局方向都由系统语言控制。当它是从右到左的时,所有菜单、对话框、消息框等都从右到左出现。这太可怕了。 该应用程序具有内置的本地化功能(“选择您的国家/地区”)如何让应用程序本地
我有一个 Web 应用程序需要支持所有语言,包括中东语言。 经过一些阅读,在许多情况下使用 dir 标签似乎可以完成这项工作(例如,文本正确对齐,我有一个表格可以在需要时正确交换)。 我正在使用 An
标记是这样的: p {direction: rtl;} code{direction: ltr !important;}
连接字符串时,如何让 Swift 遵循从右到左的语言环境设置? import Foundation var leftString = "1" let rightString = "2" let con
我在 上看到这个网站上的很多问题ls 排序 但我需要的是一个排序的输出 ls -ltr (按文件名排序) 因为我还需要文件大小和日期进行比较。 我试过 |排序 -k , |排序 , ls-1ltr 没
似乎无法找到有关以下内容的任何明确信息:在完全删除 SQL 逻辑服务器的情况下,Azure SQL 数据库的 LTR 备份是否可以恢复(可能是意外或管理员帐户泄露)。 换句话说,删除整个逻辑 SQL
我在连接包含阿拉伯字符的字符串时遇到了一些奇怪的行为,虽然我无法阅读阿拉伯文本,但看起来确实很明显发生了一些奇怪的事情,因为它似乎在重新排列文本/字符的顺序。代码未被使用。 var concat =
我在为客户开发网站时遇到了一个棘手的情况。我正在建立的网站有英文版和阿拉伯文版。当然,该网站的阿拉伯语版本是从右到左显示的,因为阿拉伯语是从右到左阅读的。 我为英语和阿拉伯语版本的索引页面构建了一个
我有一个位于 LFR 中的法语网站(从左到右) 并且客户想要用希伯来语翻译该站点,从而将其转换为 RTL(从右到左)。在所有希伯来语网站中,设计是相反的 https://he.wikipedia.or
我有以下 Bootstrap 代码,需要在不使用 Bootstrap 的情况下将导航中元素的方向更改为从右到左而不是从左到右(使元素 1 从右开始第一个)- rtl ,我也尝试在 ul 中使用 dir
如您所知,许多 ui 组件和开发工具不支持 rtl ,我们可以将其称为 flipping text ,因为结果与示例相同: 左转 سلام salam متن راهنما word RTL word
我正在开发一个支持两种语言的应用程序:英语(“en”)和波斯语(“fa”)。我在 AndroidManifest.xml 中设置了 android:supportsRtl="false" 因为我需要所
我知道了 site 我正在使用 cufon 将文本转换为我自己的字体。 问题是文本是反向显示的。 我正在使用名为 cunfonRTL.js 的 JavaScript 文件,内容是: var Cufon
我有一个元素数组,长度会改变,但它总是可以被 8 整除(8,16,24,32,40,48..等)。 我正在尝试切掉前 8 个元素,然后返回它们。然后将接下来的 8 个元素切片并反向返回。 并重复直到数
我的应用有一个包含许多 UIBarButtonItem 的 UIToolBar。 喜欢这张图片: 但是当我使应用程序可本地化时,当 RTL 语言选择了 UIToolBar 时,它会变成这样: 如何始终
我是一名优秀的程序员,十分优秀!